package com.yu.crm.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yu.crm.domain.pojo.BimDictItem;
import com.yu.crm.service.impl.BimDictItemService;
import com.yxzz.common.helper.valid.ValidatorHelpers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据字典详情表 前端控制器
 * </p>
 *
 * @author pan
 * @since 2020-09-22
 */
@Api(tags = "字典表详情")
@RestController
@RequestMapping("/bim-dict-item")
public class BimDictItemController {

    @Autowired
    BimDictItemService dictItemService;

    @ApiOperation("获取字典详情列表")
    @GetMapping("list")
    public List<BimDictItem> list(Long dictId) {
        QueryWrapper<BimDictItem> wrapper = new QueryWrapper<>();
        wrapper.eq("dict_id", dictId);
        return dictItemService.list(wrapper);
    }

    @ApiOperation("字典详情编号")
    @GetMapping("detail/{id}")
    public BimDictItem detail(@PathVariable Long id) {
        ValidatorHelpers.notEmpty(id, "字典详情编号不能为空");
        return dictItemService.getById(id);
    }

    @ApiOperation("修改新增字典详情")
    @GetMapping("save-or-update")
    public void saveOrUpdate(BimDictItem bimDictItem) {
         dictItemService.saveOrUpdate(bimDictItem);
    }
}

